//
//  NetSettingViewController.m
//  LoveListen
//
//  Created by 王喆 on 15/7/7.
//  Copyright (c) 2015年 王喆. All rights reserved.
//

#import "NetSettingViewController.h"

@interface NetSettingViewController ()<UITableViewDataSource,UITableViewDelegate>

{
    NSInteger _current;
    
    UITableViewCell *_cell;
}

@end

@implementation NetSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _current = 0;
    [self showUI];
    // Do any additional setup after loading the view.
}

-(void)showUI{
    self.dataArr = [[NSMutableArray alloc]initWithObjects:@"仅wifi收听",@"用wifi+4G/3G/2G收听", nil];
    
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0,kScreenSize.width , kScreenSize.height) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 50;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellID"];
    
    [self.view addSubview:self.tableView];
    
    
    [self.tableView reloadData];
    
    
    
}

#pragma mark UITableView
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataArr.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    _cell = [tableView dequeueReusableCellWithIdentifier:@"cellID" forIndexPath:indexPath];
    
        _cell.textLabel.text=  _dataArr[indexPath.row];
   
   
    return _cell;
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    _current = indexPath.row;
    if (indexPath.row == 1) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"'亲,更改网络设置为wifi+3G2G',如此播放时可能会消耗你的移动网络哦" message:nil delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil];
        alert.alertViewStyle = UIAlertActionStyleDefault;
        [alert show];
        
        
    }
    
    [self.tableView reloadData];
    
}

- (UITableViewCellAccessoryType)tableView:(UITableView*)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath*)indexPath

{
    
    if(_current==indexPath.row&&_current!=-1)
        
    {
        
        return UITableViewCellAccessoryCheckmark;
        
    }
    
    else
        
    {
        
        return UITableViewCellAccessoryNone;
        
    }
    
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
